sequence = [1]
while sequence[-1] < 10**18:
sequence.append(sequence[-1]*2)
sequence.pop()
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
print(n)
for i in range(n):
print(i+1, min([j for j in sequence if a[i] <= j]) - a[i])
#include <bits/stdc++.h>
using namespace std;
// was doing
int main()
{
long long int t;
cin >> t;
while (t--)
{
long long int n;
cin >> n;
long long int arr[n];
for (long long int i = 0; i < n; i++)
{
cin >> arr[i];
}
vector<pair<long long int, long long int>> v;
for (int i = 0; i < n; i++)
{
v.push_back(make_pair(arr[i], i + 1));
}
sort(v.begin(), v.end());
cout << n - 1 << endl;
for (int i = 1; i < n; i++)
{
if (v[i].first % v[i - 1].first == 0)
{
cout << v[i].second << " " << v[i - 1].first << endl;
v[i].first = v[i].first + v[i - 1].first;
}
else
{
int p = v[i].first / v[i - 1].first;
p++;
cout << v[i].second << " " << (p * v[i - 1].first - v[i].first) << endl;
v[i].first = p * v[i - 1].first;
}
}
/*long long int mini = INT_MAX;
for (long long int i = 0; i < n; i++)
{
mini = min(arr[i], mini);
}
cout << n << endl;
for (long long int i = 0; i < n; i++)
{
long long int k = arr[i] / mini;
if (arr[i] % mini == 0)
{
if (k % 2 == 1)
{
cout << (i + 1) << " " << mini << endl;
}
else
{
cout << (i + 1) << " " << 2 * mini << endl;
}
}
else
{
if (k % 2 == 0)
{
cout << (i + 1) << " " << ((k + 2) * mini - arr[i]) << endl;
}
else
{
cout << (i + 1) << " " << (k + 1) * mini - arr[i] << endl;
}
}
}*/
}
}
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |